<?php
require 'db.php';
require 'function.php';
$action = isset($_GET['a'])?$_GET['a']:'index';
switch ($action) {
	case 'index':
		$data = select("select * from category");
		$data = categoryTree($data);
		// p($data);exit;
		require 'view/index.html';
		break;
	case 'add':
		require 'view/add.html';
		break;	
	case 'doadd':
	// echo $_POST['cname'];exit;
		execute("insert into category (cname,pid) 
			values('{$_POST['cname']}',{$_POST['pid']})");
		header('location:?a=index');
	default:
		
		break;
}